package com.ls.lserp.modules.setting.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ls.lserp.common.persistence.Page;
import com.ls.lserp.common.service.CrudService;
import com.ls.lserp.modules.setting.dao.PersonnelDao;
import com.ls.lserp.modules.setting.entity.Personnel;



@Service
@Transactional(readOnly = true)
public class PersonnelService extends CrudService<PersonnelDao, Personnel>{
    
    @Autowired
    private PersonnelDao  personnelDao;

    /**
     * @Title: findList
     * @Description: 查询
     * @param @param page
     * @param @param PeopleGroup
     * @param @return
     * @return Page<PeopleGroup> 
     * @throws
     */
   public Page<Personnel> findList(Page<Personnel> page, Personnel personnel) {
       // 设置分页参数
	   personnel.setPage(page);
       // 执行分页查询
       page.setList(personnelDao.findList(personnel));
       
       return page;
   }
   
   
   /**
	  * @Title: saveUserGroup
	  * @Description: 保存数据
	  * @param @param 
	  * @return void 
	  * @throws
	  */
    
    @Transactional(readOnly = false)
	  public void saveUserGroup(Personnel personnel) {
		// 判断新建编辑
		//若为null 执行插入语句（新建）
		if (personnel.getId()==null){
			personnel.preInsert();
			System.out.println(personnel.getCreateDate());
			personnelDao.insertUserGroup(personnel);
		// 编辑
		}else{
			// 更新数据
			personnel.preUpdate();
			personnelDao.update(personnel);
			
		}
	}
    
    /**
	  * @Title: deletePersonnel
	  * @Description: 删除
	  * @param @param companyUser
	  * @return void 
	  * @throws
	  */
	
	@Transactional(readOnly = false)
	public void deletePersonnel(Personnel personnel) {
		
		// 逻辑删除
		personnelDao.delete(personnel);

	}
 
   
}
